package com.itheima.job;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Test05 {
    public static void main(String[] args) throws Exception{
        Class clazz = Class.forName("com.itheima.job.Person");
        Constructor con = clazz.getConstructor(int.class, String.class);
        Person per = (Person) con.newInstance(23, "张三");

        Method method = clazz.getDeclaredMethod("setName", String.class);
        method.setAccessible(true);
        method.invoke(per,"李四");
        System.out.println(per);
    }
}
